<?php

namespace App;

use Illuminate\Foundation\Auth\Cate as Authenticatable;
use Illuminate\Database\Eloquent\Model;
class Cate extends Model
{
	public $timestamps = false;
	public $table='cate';
    public function insert_do($arr=array()){
    	return self::insert($arr);
    }
    public function getAll(){
    	return self::where('cate_status',0)->get();
    }
    public function getSome(){
    	return self::where('parent_id',0)->get();
    }
    public function getOne($id){
    	return self::where('cate_id',$id)->get();
    }
    public function updateOne($id,$arr=array()){
        return self::where('cate_id',$id)->update($arr);
    }
    public function getField($id){
		return self::where('cate_id',$id)->update(['cate_status'=>1]);
	}
    public function getLevel($data,$parent_id=0,$level="")
	{
		static $result = array();
		foreach ($data as $key => $value)
		{
			if($value['parent_id'] == $parent_id)
			{
				$value['level'] = $level;
				$result[] = $value;
				$this->getLevel($data,$value['cate_id'],$level."&nbsp;&nbsp;&nbsp;&nbsp;");
			}
		}
		return $result;
	}
}
